<?php
/**
 * Created by PhpStorm.
 * User: CCJK
 * Date: 2018/4/19
 * Time: 17:49
 */
namespace AppBundle\EventSubscriber;

use AppBundle\Common\Log;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;

class ExceptionSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        //Log::log("getSubscribedEvents");
        // return the subscribed events, their methods and priorities
        // 返回被订阅的事件，以及它们的方法和属性
        return array(
            KernelEvents::EXCEPTION => array(
                array('processException', 10),
                array('logException', 0),
                array('notifyException', -10),
            )
        );
    }

    public function processException(GetResponseForExceptionEvent $event)
    {
        Log::log("processException");
    }

    public function logException(GetResponseForExceptionEvent $event)
    {
        Log::log("logException");
    }

    public function notifyException(GetResponseForExceptionEvent $event)
    {
        Log::log("notifyException");
    }
}